// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IMarketBook.cs" company="Open Trader">
//   Copyright (c) David Denis (david.denis@systemathics.com)
// </copyright>
// <summary>
//   |  Open Trader - The Open Source Systematic Trading Platform
//   |
//   |  This program is free software: you can redistribute it and/or modify
//   |  it under the terms of the GNU General Public License as published by
//   |  the Free Software Foundation, either version 2 of the License, or
//   |  (at your option) any later version.
//   |
//   |  This program is distributed in the hope that it will be useful,
//   |  but WITHOUT ANY WARRANTY; without even the implied warranty of
//   |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   |  GNU General Public License for more details.
//   |
//   |  You should have received a copy of the GNU General Public License
//   |  along with this program.  If not, see http://www.gnu.org/licenses
//   |
//   |  Up to date informations about Open Trader can be found at :
//   |    http://opentrader.org
//   |    http://opentrader.codeplex.com
//   |
//   |  For professional services, please visit us at :
//   |    http://www.systemathics.com
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Org.OpenTrader.Framework.Forge.Interfaces
{
    #region Using Directives

    using Org.OpenTrader.Framework.Forge.Events;

    #endregion

    /// <summary>
    /// The i market book.
    /// </summary>
    public interface IMarketBook
    {
        #region Properties

        /// <summary>
        /// The ask depth.
        /// </summary>
        /// <returns>
        /// The ask depth.
        /// </returns>
        short AskDepth { get; }

        /// <summary>
        /// The sellers (0: best price)
        /// </summary>
        MarketBookCell[] Asks { get; }

        /// <summary>
        /// The bid depth.
        /// </summary>
        /// <returns>
        /// The bid depth.
        /// </returns>
        short BidDepth { get; }

        /// <summary>
        /// The instrument this book is dedicated to
        /// </summary>
        // IInstrumentStaticData InstrumentStaticData { get; }
        /// <summary>
        /// The nuyers (0: best price)
        /// </summary>
        MarketBookCell[] Bids { get; }

        /// <summary>
        /// Depth of this book
        /// </summary>
        short Depth { get; }

        #endregion

        #region Public Methods

        /// <summary>
        /// The ask limit.
        /// </summary>
        /// <param name="price">
        /// The price.
        /// </param>
        /// <returns>
        /// The ask limit.
        /// </returns>
        int AskLimit(double price);

        /// <summary>
        /// The ask price.
        /// </summary>
        /// <param name="size">
        /// The size.
        /// </param>
        /// <returns>
        /// The ask price.
        /// </returns>
        double AskPrice(int size);

        /// <summary>
        /// The ask price.
        /// </summary>
        /// <param name="size">
        /// The size.
        /// </param>
        /// <param name="price">
        /// The price.
        /// </param>
        /// <param name="depth">
        /// The depth.
        /// </param>
        /// <param name="nbexec">
        /// The nbexec.
        /// </param>
        /// <param name="tottrd">
        /// The tottrd.
        /// </param>
        /// <returns>
        /// The ask price.
        /// </returns>
        bool AskPrice(int size, ref double price, ref int depth, ref int nbexec, ref double tottrd);

        /// <summary>
        /// The ask price nominal.
        /// </summary>
        /// <param name="nominal">
        /// The nominal.
        /// </param>
        /// <returns>
        /// The ask price nominal.
        /// </returns>
        double AskPriceNominal(double nominal);

        /// <summary>
        /// The bid limit.
        /// </summary>
        /// <param name="price">
        /// The price.
        /// </param>
        /// <returns>
        /// The bid limit.
        /// </returns>
        int BidLimit(double price);

        /// <summary>
        /// The bid price.
        /// </summary>
        /// <param name="size">
        /// The size.
        /// </param>
        /// <returns>
        /// The bid price.
        /// </returns>
        double BidPrice(int size);

        /// <summary>
        /// The bid price.
        /// </summary>
        /// <param name="size">
        /// The size.
        /// </param>
        /// <param name="price">
        /// The price.
        /// </param>
        /// <param name="depth">
        /// The depth.
        /// </param>
        /// <param name="nbexec">
        /// The nbexec.
        /// </param>
        /// <param name="tottrd">
        /// The tottrd.
        /// </param>
        /// <returns>
        /// The bid price.
        /// </returns>
        bool BidPrice(int size, ref double price, ref int depth, ref int nbexec, ref double tottrd);

        /// <summary>
        /// The bid price nominal.
        /// </summary>
        /// <param name="nominal">
        /// The nominal.
        /// </param>
        /// <returns>
        /// The bid price nominal.
        /// </returns>
        double BidPriceNominal(double nominal);

        /// <summary>
        /// Get a snapshot of the current book
        /// </summary>
        /// <returns>
        /// </returns>
        FeedEventArgs.MarketBookUpdate GetSnapshot();

        /// <summary>
        /// Handle this update
        /// </summary>
        /// <param name="update">
        /// </param>
        void HandleUpdate(FeedEventArgs.MarketBookUpdate update);

        /// <summary>
        /// The mid price.
        /// </summary>
        /// <param name="depth">
        /// The depth.
        /// </param>
        /// <returns>
        /// The mid price.
        /// </returns>
        double MidPrice(int depth);

        /// <summary>
        /// The mid price.
        /// </summary>
        /// <returns>
        /// The mid price.
        /// </returns>
        double MidPrice();

        /// <summary>
        /// The spread.
        /// </summary>
        /// <param name="depth">
        /// The depth.
        /// </param>
        /// <returns>
        /// The spread.
        /// </returns>
        double Spread(int depth);

        /// <summary>
        /// The spread.
        /// </summary>
        /// <returns>
        /// The spread.
        /// </returns>
        double Spread();

        /// <summary>
        /// The spread.
        /// </summary>
        /// <param name="depth">
        /// The depth.
        /// </param>
        /// <param name="spread">
        /// The spread.
        /// </param>
        /// <returns>
        /// The spread.
        /// </returns>
        bool Spread(int depth, ref double spread);

        /// <summary>
        /// The spread.
        /// </summary>
        /// <param name="spread">
        /// The spread.
        /// </param>
        /// <returns>
        /// The spread.
        /// </returns>
        bool Spread(ref double spread);

        #endregion
    }
}